home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / biz / cloan / pprx_WebAnimDe.lha / pprx_WebAnimDes / WebAnimDesigner093.pprx < prev    next >
Text File  |  1997-10-12  |  30KB  |  953 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1997, Andres Paabo. 'SaveAnimGif.pprx 1.7 script is copyright Cloanto (see bottom  portion  of this script)*/
  2.  
  3. /* $VER: WebAnimDesigner.pprx 0.92 */
  4.  
  5. /** ENG
  6.  This script is intended to assist in the creation of animated gifs for web pages. NOTE this program does not create animated gifs itslf. It only helps design the anim or animbrush that is used as a source for creating the animated gifs. The animated gifs have to be created with other programs such as Cloanto's DefineAnimGif.pprx and SaveAnimGif.pprx. However since this runs on Personal Paint. and for convenience, this script will call on Personal Paint's 'SaveAnimGiif.pprx' (in slightly modified form) and pass information to it.
  7. */
  8.  
  9.  
  10.  
  11. IF ARG(1, EXISTS) THEN
  12.     PARSE ARG PPPORT
  13. ELSE
  14.     PPPORT = 'PPAINT'
  15.  
  16. IF ~SHOW('P', PPPORT) THEN DO
  17.     IF EXISTS('PPaint:PPaint') THEN DO
  18.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  19.         DO 30 WHILE ~SHOW('P',PPPORT)
  20.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  21.         END
  22.     END
  23.     ELSE DO
  24.         SAY "Personal Paint could not be loaded."
  25.         EXIT 10
  26.     END
  27. END
  28.  
  29. IF ~SHOW('P', PPPORT) THEN DO
  30.     SAY 'Personal Paint Rexx port could not be opened'
  31.     EXIT 10
  32. END
  33.  
  34. ADDRESS VALUE PPPORT
  35. OPTIONS RESULTS
  36. OPTIONS FAILAT 10000
  37.  
  38.  
  39.  
  40.  
  41.  
  42. /*********ANIM IS SET UP****WHAT TO DO NEXT***************************/
  43.  
  44.  
  45. openWAD= getclip('openWAD'); if openWAD = "" then DO
  46. /*******************ENSURES SCREEN NOT TOO SMALL & STUFF IS WITHIN SCREEN*****************/
  47. accept = 0
  48. GET 'SCREENW'
  49. scw = result
  50. if scw >= 640 then DO
  51.     GET 'SCREENH'
  52. sch = result
  53.     if sch >= 400 then DO
  54.         GET 'IMAGEW'
  55.             imgw = result
  56.             if imgw <= scw then DO
  57.             GET 'IMAGEH'
  58.             imgh = result
  59.                 if imgh <= sch then accept = 1
  60. END
  61. END
  62. END
  63. if accept = 0 then  DO
  64.     Requestnotify 'TITLE "CHANGE SCREEN or IMAGE SIZE" PROMPT  "For viewability, screen size must be 640x 400 or greater, and image size equal or less the screen size"'
  65.     EXIT 0
  66.     END
  67. /********/
  68. call TITLEPAGE
  69. RequestResponse 'TITLE "OPEN NEW PROJECT" PROMPT "Opening a project requires an animbrush be present. Load an animbrush?"'
  70. if rc~=0 then EXIT 0
  71. if rc=0 then call LOADER
  72.  
  73. END
  74. /********THE ABOVE IS DONE ONLY AT VERY START********/
  75.  
  76. numcolors2=getclip('numcolors2')
  77. GET 'COLORS'
  78. numcolors=result 
  79. if numcolors = 256 then DO; RequestResponse 'PROMPT "You must start on the source page. Proceed if okay. Cancel if not."';if rc~=0 then EXIT 0;END  
  80. if numcolors = numcolors2 then DO
  81.  switchenvironment
  82.  GET 'COLORS'
  83.  numcolors=result
  84. end
  85.  
  86. SETFRAMEPOSITION 1
  87.  
  88. REQUESTER:
  89. txt_gad_title = 'WEB ANIM DESIGNER 0.92 by A.Paabo for use with Personal Paint 7.+'
  90. txt_gad_transp = 'transparency'
  91. txt_gad_dispose = 'dispose'
  92. txt_gad_optimize = 'Optimization:'
  93. txt_gad_optimnone = 'None (Constant size & position)'
  94. txt_gad_optimdelta = 'Deltas (Varying size & position)'
  95. txt_gad_optimbndy= 'Boundaries (Varying size & position)'
  96. txt_gad_operation = 'select operation'
  97. txt_gad_new = '1.OPEN new project with new animbrush '
  98. txt_gad_preview = '2.SIMULATE animgif in 2nd environment'
  99. txt_gad_pickup = '3.PICK UP anim as annotated animbrush'
  100. txt_gad_final = '4.MAKE ANIMGIF via Cloanto SaveAnimGif'
  101. txt_gad_drawrect = 'show frame rectangles'
  102. txt_gad_curglobal = 'get new global size'
  103. txt1 = '--BELOW APPLIES ONLY TO ANIMGIF SIMULATION VIEWING--'
  104.  
  105. transpcol = getclip('transpcol'); if transpcol = "" then transpcol=0
  106. X0 = getclip('X0')
  107. Y0 = getclip('Y0')
  108. X1 = getclip('X1')
  109. Y1 = getclip('Y1')
  110. GETFRAMES
  111. frames=result 
  112. transp=getclip('transp')
  113.  if transp = "" then transp = 1
  114. dispose = getclip('dispose')
  115.  if dispose = "" then dispose = 1
  116. operation = getclip('operation')
  117. if operation = "" then operation =0
  118. optimization= getclip('optimization')
  119.  if optimization="" then optimization = 0
  120. drawrect= getclip('drawrect')
  121.  if drawrect="" then drawrect=1
  122. curglobal = getclip('curglobal')
  123.  if curglobal="" then curglobal=0
  124. Request '"'txt_gad_title'" ' ||,
  125.           ' "CHECK = ""'txt_gad_transp'"", 'transp' ' ||,
  126.         ' CHECK = ""'txt_gad_dispose'"", 'dispose' ' ||,
  127.        ' CYCLE = ""'txt_gad_optimize'"", 3, 'optimization', ""'txt_gad_optimnone'"",""'txt_gad_optimbndy'"", ""'txt_gad_optimdelta'"" ' ||,  
  128.   ' CYCLE = ""'txt_gad_operation'"", 4, 'operation', ""'txt_gad_new'"",""'txt_gad_preview'"", ""'txt_gad_pickup'"", ""'txt_gad_final'"" '||,
  129. ' TEXT = ""'txt1'"" ' ||,
  130. ' CHECK = ""'txt_gad_curglobal'"", 'curglobal' ' ||,
  131.  ' CHECK = ""'txt_gad_drawrect'"", 'drawrect' "'
  132.                    if rc~=0 then EXIT 0
  133.          if rc = 0 then DO
  134.             transp = RESULT.1
  135.             dispose = RESULT.2
  136.             optimization = RESULT.3
  137.                operation = RESULT.4
  138.                 curglobal = RESULT.5
  139.                 drawrect = RESULT.6
  140.                               END
  141. call setclip('transp', transp)
  142. call setclip('dispose', dispose)
  143. call setclip('operation', operation)
  144. call setclip('optimization', optimization)
  145. call setclip('drawrect', drawrect)
  146. call setclip('curglobal', curglobal)
  147.  
  148. if operation = 0 then CALL LOADER
  149. if transp= 0 then SET '"TRANSP=0"'      
  150.  if transp=1 then SET '"TRANSP=1"'
  151. if operation = 2 then call PICKUPABRUSH
  152. if operation = 3 then call PICKUPABRUSH
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. if operation =1 then DO    /*find new gloabl area */
  161.     if curglobal = 1 then CALL GLOBALAREA
  162.    END 
  163.  
  164. SWITCHENVIRONMENT          
  165. DELETEFRAMES ALL
  166. CLEARIMAGE
  167. if numcolors < 256 then numcolors2 = numcolors*2
  168. if numcolors = 256 then numcolors2 = numcolors
  169. Set 'FORCE "COLORS='numcolors2'"'
  170.     col = '153 153 153'
  171.     col2 = '204 204 204'
  172.     Setcolors 'FROM "'numcolors2-1'" COLORS "'col'"'
  173.      Setcolors 'FROM "'numcolors2-2'" COLORS "'col2'"'
  174.  
  175. SETPEN 'BACKGROUND' numcolors2-1
  176. call setclip('numcolors2', numcolors2) 
  177. Clearimage
  178. CALL TEXTSRECT
  179. ADDFRAMES 
  180. SWITCHENVIRONMENT
  181.  
  182.  
  183. /*********BEGIN***********/
  184. SETFRAMEPOSITION 1
  185.  
  186. /*************************/
  187. if optimization=0 then DO
  188.         
  189.     DO frm = 1 to frames
  190.         SETFRAMEPOSITION frm
  191.         GETFRAMEDELAY frm
  192.         delay = result
  193.          Definebrush x0 y0 x1 y1
  194.        setbrushhandle UPPERLEFT
  195.         SWITCHENVIRONMENT
  196.         SETFRAMEPOSITION frm
  197.         SETFRAMEDELAY delay
  198.         usebrushpalette
  199.         remapimage
  200.         if dispose = 0 then Putbrush x0 y0
  201.                if frm < frames then  ADDFRAMES 1 AFTER
  202.           if dispose = 1 then  Putbrush x0 y0 
  203.         SWITCHENVIRONMENT      
  204.                END
  205.  END
  206. /*********BOUNDARIES*****************/
  207. if optimization=1 then DO
  208.         
  209.     DO frm = 1 to frames
  210.         SETFRAMEPOSITION frm
  211.           GETFRAMEDELAY frm
  212.         delay = result
  213.         GetImageAttributes 'BOUNDARIES'
  214.         PARSE VAR RESULT bx0 by0 bx1 by1 rest
  215.          Definebrush bx0 by0 bx1 by1
  216.        setbrushhandle UPPERLEFT
  217.         SWITCHENVIRONMENT
  218.         SETFRAMEPOSITION frm
  219.         SETFRAMEDELAY delay
  220.         usebrushpalette
  221.         remapimage
  222.           if dispose = 0 then Putbrush bx0 by0
  223.                if frm < frames then  ADDFRAMES 1 AFTER
  224.           if dispose = 1 then  Putbrush bx0 by0
  225.             freebrush force
  226.             Setpen 'FOREGROUND' numcolors2-3
  227.             if drawrect=1 then Drawrectangle bx0 by0 bx1 by1
  228.             SWITCHENVIRONMENT
  229.                   END
  230.  END 
  231.  
  232. /********DELTA******************/
  233. if optimization=2 then DO
  234.   tbmap.0 = 0
  235. tbmap.1 = 0
  236. GET 'COLORS'
  237. bcolors = result
  238. /*get bdepth from number of colros*/
  239. DO bdepth = 1 to 8
  240. if bcolors = (2 ** bdepth) THEN
  241. BREAK
  242. END
  243. bwidth = X1-X0
  244. bheight = Y1-Y0
  245.  
  246. AllocateBitmap bwidth bheight bdepth
  247. tbmap.0 = result
  248. AllocateBitmap bwidth bheight bdepth
  249. tbmap.1 = result
  250. SETFRAMEPOSITION 1
  251.   GETFRAMEDELAY 1
  252.         delay = result
  253. DefineBrush X0 Y0 X1 Y1
  254. setbrushhandle upperleft
  255. SWITCHENVIRONMENT
  256. if dispose=1 then ADDFRAMES 1 AFTER
  257. usebrushpalette
  258. remapimage
  259. Putbrush X0 Y0
  260. if dispose = 0 then ADDFRAMES 1 AFTER
  261. SETFRAMEDELAY delay
  262. SWITCHENVIRONMENT
  263.  
  264. DO frm = 1 to frames-1
  265. SETFRAMEPOSITION frm
  266.  GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.0
  267. SETFRAMEPOSITION frm+1
  268. GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.1
  269. GetBitmapDelta  tbmap.0 tbmap.1
  270. PARSE VAR RESULT delx0 dely0 delx1 dely1
  271.  
  272. if delx0 < 0 then DO  /*means a value of -1 meaning identical*/
  273.         delx0 = 0
  274.         dely0 = 0
  275.         delx1 = 0
  276.         dely1 = 0
  277.         END
  278.  
  279. dx0 = X0 + delx0 
  280. dy0 = Y0 + dely0
  281. dx1 = X0 + delx1 + 1
  282. dy1 = Y0 + dely1 + 1
  283.  
  284. Definebrush dx0 dy0 dx1 dy1
  285.          SwitchENvironment /*to switch env*/
  286.         SETFRAMEPOSITION frm+1
  287.  GETFRAMEDELAY frm
  288.         delay = result
  289.        Usebrushpalette
  290.         remapimage
  291.         SetBrushHandle UPPERLEFT
  292.                 if dispose = 0 then PutBrush dx0 dy0 
  293.                 if frm <frames-1 then ADDFRAMES 1 AFTER
  294.                 if dispose = 1 then PutBrush dx0 dy0 
  295.                 FreeBrush FORCE
  296.                 SETPEN 'FOREGROUND' numcolors2-3
  297.                 if drawrect=1 then DrawRectangle dx0 dy0 dx1 dy1 /*the delta*/
  298.             SETFRAMEDELAY delay
  299.             SWITCHENVIRONMENT
  300.  
  301.  
  302.     END
  303.   
  304.  END
  305. /***********************/
  306.  
  307.   SwITCHENVIRONMENT 
  308.   SETFRAMEPOSITION 1
  309.     PLAY 
  310.  
  311.  
  312.  
  313. /***********************************/
  314.  
  315.  
  316.  
  317. /*********************************************/
  318. EXIT
  319. /*****************************************/
  320. GLOBALAREA:
  321.                  maxdx = 0
  322.                 maxdy= 0
  323.                 mindx = 4000
  324.                 mindy = 4000
  325.  DO frm = 1 to frames
  326.             SETFRAMEPOSITION frm
  327.             GetImageAttributes 'BOUNDARIES'
  328.             PARSE VAR RESULT dx0 dy0 dx1 dy1 rest
  329.             if dx0 < mindx then mindx = dx0
  330.             if dy0 < mindy then mindy = dy0
  331.             if dx1 > maxdx then maxdx = dx1
  332.             if dy1 > maxdy then maxdy = dy1
  333.               END
  334.             X0 = mindx
  335.             Y0 = mindy
  336.             X1 = maxdx
  337.             Y1 = maxdy 
  338.         
  339.            call setclip('X0', X0)
  340.            call setclip('Y0', Y0)    
  341.             call setclip('X1', X1)
  342.             call setclip('Y1', Y1)    
  343. RETURN
  344. /***********************************************/
  345. TEXTSRECT:
  346. GET 'IMAGEW'
  347. imgw = RESULT
  348. Xmid = TRUNC(imgw/2)
  349. SETPEN 'FOREGROUND' numcolors2-2
  350. Text 'TEXT "SIMULATION OF ANIM GIF ON WEB PAGE" "fonts:" "times" "20" "of" "'Xmid'" "40" CENTER'
  351. Text 'TEXT "(IF ACTIVE) LARGE RECTANGLE SHOWS GLOBAL ANIMGIF SIZE. SMALLER RECTANGLES SHOW FRAME SIZES "fonts:" "times" "10" "of" "'Xmid'" "60" CENTER'
  352.  
  353. if transp=1 then DO
  354. if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  355. if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  356.     END
  357. if transp=0 then DO
  358. if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  359. if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  360. eND
  361. if optimization = 0 then Text 'TEXT "OPTIMIZATION=NONE (CONST FRAME & POSTITION)" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  362. if optimization =1  then Text 'TEXT "OPTIMIZATION=BOUNDARIES" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  363. if optimization = 2 then Text 'TEXT "OPTIMIZATION=DELTA" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  364.  
  365. freebrush FORCE
  366. if drawrect=1 then DrawRectangle X0 Y0 X1 Y1  
  367. RETURN
  368. /*********************************************/
  369. LOADER:
  370. CLEARIMAGE
  371. FREEENVIRONMENT FORCE
  372. SWITCHENVIRONMENT 
  373.  
  374. GetBrushAttributes 'FRAMES'
  375. frames = RESULT
  376. IF frames < 2 then DO
  377.  Loadanimbrush
  378. if rc~=0 then EXIT 0
  379. END
  380.  
  381.  
  382. GetbrushAttributes 'COLORS'
  383. numcolors = RESULT
  384. Set 'FORCE "COLORS='numcolors'"'
  385. copyenvironment FORCE
  386.  
  387. Set 'FORCE "TRANSP= 1"'
  388. GET 'IMAGEW'
  389. imgw = RESULT
  390. GET 'IMAGEH'
  391. imgh = RESULT
  392. imgmid = TRUNC(imgw/2)
  393.  
  394. GetBrushAttributes 'FRAMES'
  395. frames = RESULT
  396. GetBrushAttributes WIDTH
  397. width = result
  398. if width > imgw-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too wide. Use larger screen size"';EXIT 0; END
  399. GetBrushAttributes HEIGHT
  400. height = RESULT
  401. if height > imgh-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too high. Use larger screen size."'; EXIT 0; END
  402. x0 = TRUNC((imgw-width)/2)
  403. y0 = TRUNC((imgh-height)/2)
  404. x1 = x0 + width
  405. y1 = y0 + height
  406. setbrushhandle UPPERLEFT
  407.  
  408.  
  409. UseBrushPalette
  410. GetBrushAttributes 'TRANSPARENCY'
  411.             transp = RESULT
  412.                 IF transp=0 then transpcol = 0
  413.                If transp >0 then DO
  414.                 GetBrushAttributes 'TRANSPARENTCOLOR'
  415.                 transpcol = RESULT
  416.                 setpen 'BACKGROUND' transpcol
  417.                     END
  418. /************CLEAR TO ABRS TRANSP COLOR & STAMP DOWN*************************/
  419. GetBrushInfo 'ANNOTATION'
  420. frame_annot = RESULT
  421.  
  422. delayannot = 0
  423. loop = -1
  424. delay. = 0
  425. IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
  426. delayannot=1
  427.     loop = WORD(frame_annot, 2)
  428.     IF ~DATATYPE(loop, 'W') THEN
  429.         loop = -1
  430.     DO frm = 1 TO frames
  431.         del = WORD(frame_annot, 3+frm)
  432.         IF DATATYPE(del, 'W') THEN
  433.             delay.frm = del
  434. delay.frm = TRUNC(delay.frm*(60/100))
  435.     END
  436. END
  437. SETPEN 'BACKGROUND' transpcol
  438. ClearImage
  439. ADDFRAMES frames AFTER
  440. DO frm = 1 TO frames
  441. SETFRAMEPOSITION frm
  442. if delayannot=1 then SETFRAMEDELAY delay.frm
  443. if delayannot = 0 then SETFRAMEDELAY 10
  444. SetBrushAttributes 'FRAMEPOSITION' frm
  445. Usebrushpalette
  446. Putbrush X0 y0
  447. END
  448.  
  449. SETFRAMEPOSITION 1
  450.  
  451.             call setclip('X0', X0)
  452.            call setclip('Y0', Y0)    
  453.             call setclip('X1', X1)
  454.             call setclip('Y1', Y1) 
  455.             call setclip('openWAD', 1)   
  456. freebrush  /*not needed as we make the preview version from the image*/
  457.  
  458. PLAY 3
  459.  
  460. Requestnotify 'TITLE "PROJECT IS NOW SET UP" PROMPT " NEW PROJECT IS SET UP.   Always keep area around the animation a perfectly clean animation transparent color. You can work on this anim now. Then enter Web Anim Designer at ANY time to render your animation to a simulation of an animated gif on a web page."'
  461.  
  462.  
  463. EXIT 0
  464. /****************************************/
  465. TITLEPAGE:
  466. Clearimage
  467. GET 'IMAGEW'
  468. imgw = RESULT
  469. imgmid = TRUNC(imgw/2)
  470. Text 'TEXT "WEB ANIM DESIGNER v0.92" "fonts:" "times" "24" "of" "'imgmid'" "60" CENTER'
  471. Text 'TEXT "FOR PERSONAL PAINT 7.+ (TM Cloanto)  " "fonts:" "times" "18" "of" "'imgmid'" "90" CENTER'
  472. Text 'TEXT "DESIGN ANIMATED GIFS ON THE AMIGA WITH PERSONAL PAINT 7.+ " "fonts:" "times" "15" "of" "'imgmid'" "110" CENTER'
  473. Text 'TEXT "MAIN ANIMBRUSH DESIGNER SCRIPT BY ANDRES PÄÄBO, COPYRIGHT (c) 1997" "fonts:" "times" "11" "of" "'imgmid'" "135" CENTER'
  474. Text 'TEXT "SAVEANIMGIF.PPRX 1.7 SCRIPT (TACKED TO END IN MODIFIED FORM) IS BY CLOANTO (c) 1997" "fonts:" "times" "11" "of" "'imgmid'" "150" CENTER'
  475.  
  476. Text 'TEXT "FEATURES" "fonts:" "times" "15" "of" "'imgmid'" "180" CENTER'
  477. Text 'TEXT "-Allows creation and modification of source anims" "fonts:" "times" "15" "of" "'imgmid'" "200" CENTER'
  478. Text 'TEXT "-Recognises, shows and saves most variations of transparency and dispose " "fonts:" "times" "15" "of" "'imgmid'" "220" CENTER'
  479. Text 'TEXT "-Supports Personal Paint Delta and Boundaries optimization methods." "fonts:" "times" "15" "of" "'imgmid'" "240" CENTER'
  480. Text 'TEXT "-Supports Personal Paint time delay annotations on animbrushes." "fonts:" "times" "15" "of" "'imgmid'" "260" CENTER'
  481. Text 'TEXT "HELP GUIDE & EXAMPLES:" "fonts:" "times" "15" "of" "'imgmid'" "290" CENTER'
  482. Text 'TEXT "Go to www3.sympatico.ca/paabo/webanimdesigner.html" "fonts:" "times" "15" "of" "'imgmid'" "305" CENTER'
  483. Text 'TEXT "(CLICK SCREEN TO PROCEED)" "fonts:" "times" "15" "of" "'imgmid'" "360" CENTER'
  484.  
  485. WAITFORCLICK
  486. RETURN
  487.  
  488.  
  489.  
  490. /****************************************************/
  491. PICKUPABRUSH:
  492. if operation=3 then DO
  493.  Requestresponse 'TITLE "HANDING OVER TO SAVEANIMGIF.PPRX" PROMPT "This operation hands an annotated animbrush over to a modified version of Cloanto-s (GIF-licenced) SaveAnimGif.pprx, which  has been copied to the bottom of WebAnimDesigner.pprx. The settings in W.A.D.determine the parameters for saving. Thus the SaveAnimGif settings requester is not needed and will not appear. Continuous looping is assumed. "'
  494.     if rc ~=0 then EXIT 0
  495.         END
  496. GETFRAMES
  497. frames = result
  498. Setframeposition 1
  499. posit = 1
  500. X0 = GETCLIP('X0')
  501. Y0 = GETCLIP('Y0')
  502. X1 = GETCLIP('X1')
  503. Y1 = GETCLIP('Y1')
  504. /********get animation project info if exists****************/
  505. GetProjectInfo 'COPYRIGHT'
  506. annot = RESULT
  507. /***get time delays from source animation, convert  to 100ths if asked***/
  508. DO frm = 1 to frames  
  509. GetFrameDelay 'FRAME' frm
  510. del = RESULT
  511. delay.frm = TRUNC((del * 100/60) + 0.5)
  512. END
  513. /*******make animbrush********/
  514. DefineBrush  X0 Y0 X1 Y1 'FRAMES' frames 
  515. /*******annotate animbrush with delay timings********/
  516. loop = 1
  517. frame_annot = 'LOOP' loop 'DELAY'
  518. 
  519. DO frm = 1 TO frames 
  520.     frame_annot = frame_annot delay.frm
  521. END
  522. SetBrushInfo 'ANNOTATION "'frame_annot'"'
  523. SetBrushInfo 'COPYRIGHT "'annot'"'
  524. If operation = 2 then EXIT 0
  525.  
  526. /****************continue into other scripts*********************/
  527. /*********NOTE: THESE CALL ON THIRD PARTY SCRIPTS THAT***********/
  528. /**************ACTUALLY CREATE THE ANIMATED GIFS.*****************/
  529.  
  530. call setclip('dispose', dispose)
  531. call setclip('optimization', optimization)
  532.  
  533. CALL WADSaveAnimGif
  534.  
  535.  
  536. EXIT 0
  537.  
  538.  
  539. WADSaveAnimGif:
  540. /**********INFO FROM WEB ANIM DESIGNER***********/
  541. /*****not provided in annotated animbrush********/
  542. /*optimization = getclip('optimization');dispose = getclip('dispose')*/
  543. if optimization = 0 then optimname = 'NONE'
  544. if optimization = 1 then optimname = 'BOUNDARIES'
  545. if optimization = 2 then optimname = 'DELTA'
  546. REQUESTRESPONSE 'TITLE "SETTINGS TO BE USED" PROMPT "optimization='optimname' dispose='dispose' transp='transp'"'
  547. /**************************************************/
  548.  
  549. /************MODIFIED SaveANimGif.pprx*************************************/
  550. /****not part of this program. Provided for your convenience**********/
  551.  
  552.  
  553. /* Personal Paint Amiga Rexx script - Copyright © 1996, 1997 Cloanto Italia srl */
  554.  
  555. /* $VER: MODIFIED SaveAnimGif.pprx 1.7 */
  556. /*MODIFIED SaveAnimGif.pprx 1.7. The modifications are simple ones to allow the above host program to pass to it the parameters this program uses. Since the parameteers are passed to it, the settings requester is not needed, and that portion of the script has been removed. Also, to permit the creation of various situations other than just delta-nontransp-nodispose and boundaries-transp-dispose, explicit control of the host's variable 'optimization' is simply introduced, and more output possibilities than the above two are permitted. All modified sections are marked*/
  557.  
  558. /****MODIFICATION****remove entry script since it is already acheived at the top of this overall script***/
  559. /*******MODIFICATION ****as settings requester removed, gadget texts relating to it removed. These remain. Non English excluded in this version***/
  560.     txt_title_req  = 'Save GIF Anim-Brush'
  561.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  562.     txt_err_oldlib    = 'This script requires a newer_version of the GIF library'
  563.     txt_err_notabsh   = 'The current brush_is not an anim-brush'
  564.     txt_err_notemp    = 'No space for temporary brush'
  565.     txt_err_nomem     = 'Not enough memory'
  566.     txt_err_nosave    = 'File I/O error'
  567.  
  568.  
  569. Version 'REXX'
  570. IF RESULT < 7 THEN DO
  571.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  572.     EXIT 10
  573. END
  574.  
  575. LockGUI
  576. GetBrushAttributes 'FRAMES'
  577. frames = RESULT
  578.  
  579. IF frames < 2 THEN DO
  580.     RequestNotify 'PROMPT "'txt_err_notabsh'"'
  581.     UnlockGUI
  582.     EXIT 0
  583. END
  584.  
  585. GetBrushNumber
  586. bshnum = RESULT
  587.  
  588. SetCurrentBrush 'UNUSED'
  589. IF RC ~= 0 THEN DO
  590.     RequestNotify 'PROMPT "'txt_err_notemp'"'
  591.     UnlockGUI
  592.     EXIT 0
  593. END
  594. GetBrushNumber
  595. tbshnum = RESULT
  596.  
  597. SetCurrentBrush 'BRUSH' bshnum
  598. GetBrushInfo 'ANNOTATION'
  599. frame_annot = RESULT
  600.  
  601. loop = -1
  602. delay. = 0
  603. IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
  604.     loop = WORD(frame_annot, 2)
  605.     IF ~DATATYPE(loop, 'W') THEN
  606.         loop = -1
  607.     DO frm = 1 TO frames
  608.         del = WORD(frame_annot, 3+frm)
  609.         IF DATATYPE(del, 'W') THEN
  610.             delay.frm = del
  611.     END
  612. END
  613. use_loop = (loop >= 0)
  614. IF loop < 0 THEN
  615.     loop = 0
  616.  
  617. fnlen = LENGTH(frames)
  618. dsel = 1
  619. do_req = 1
  620. deltype = 0
  621.  
  622. GetBrushInfo 'COPYRIGHT'
  623. annot = RESULT
  624. max_annot_size = LENGTH(annot) * 2
  625. IF max_annot_size < 200 THEN
  626.     max_annot_size = 200
  627.  
  628. GetBrushAttributes 'TRANSPARENCY'
  629. transp = RESULT
  630. IF transp ~= 1 THEN
  631.     transp = 0
  632.  
  633. /*****MODIFICATION*****all matters pertaining to the settings requester have been removed since the host provides all settings data. We continue at the following lines*****/
  634.  
  635.  
  636. IF ~use_loop THEN
  637.     loop = -1
  638. frame_annot = 'LOOP' loop 'DELAY'
  639. DO frm = 1 TO frames
  640.     frame_annot = frame_annot delay.frm
  641. END
  642. SetBrushInfo 'ANNOTATION "'frame_annot'"'
  643.  
  644.  
  645. RequestFile '"'txt_title_req'" SAVEMODE'
  646. IF RC = 0 THEN DO
  647.     PARSE VALUE RESULT WITH '"' fname '"'
  648.     tempfile = 'T:PP_AnGif.'PRAGMA('ID')
  649.  
  650.     GetBrushAttributes 'FRAMEFIRST'
  651.     sv_frmin = RESULT
  652.     GetBrushAttributes 'FRAMELAST'
  653.     sv_frmax = RESULT
  654.     GetBrushAttributes 'LENGTH'
  655.     sv_frlen = RESULT
  656.     GetBrushAttributes 'FRAMEPOSITION'
  657.     sv_frpos = RESULT
  658.     Get 'ICONS'
  659.     sv_icons = RESULT
  660.  
  661.     GetBrushAttributes 'WIDTH'
  662.     bwidth = RESULT
  663.     GetBrushAttributes 'HEIGHT'
  664.     bheight = RESULT
  665.  
  666.     GetBrushAttributes 'TRANSPARENTCOLOR'
  667.     transpcol = RESULT
  668.     GetBrushAttributes 'COLORS'
  669.     bcolors = RESULT
  670.     plt_size = bcolors * 3
  671.  
  672.     Get 'PATHBSH'
  673.     PARSE VAR RESULT '"' sv_pathbsh '"'
  674.  
  675. /*****MODIFICATION****we remove the following lines because they only provide two options
  676.     IF transp = 1 THEN
  677.         pckinfo = '09'x
  678.     ELSE
  679.         pckinfo = '00'x  ******/
  680.  
  681. /*******MODIFICATION*****we replace them with these lines which provide a few more*******/
  682.     if transp = 0 then DO
  683.     if dispose = 0 then pckinfo = '06'x /*notrans nodisp*/
  684.      if dispose = 1 then pckinfo = '08'x /*notrans & dispose*/
  685.             END
  686.     if transp = 1 then DO
  687.     if dispose = 0 then pckinfo = '05'x /*trans & nodispose*/
  688.     if dispose = 1 then if transp = 1 then pckinfo = '09'x /*trans & dispose*/
  689.             END
  690. /************************************/    
  691.  
  692.  
  693.  
  694.     DO bdepth = 1 TO 8
  695.         IF bcolors = (2 ** bdepth) THEN
  696.             BREAK
  697.     END
  698.  
  699.     tbmap.0 = 0
  700.     tbmap.1 = 0
  701.     tbnum = 0
  702.     gfile_open = 0
  703.     global_plt = ''
  704.     err_msg = ''
  705.  
  706.     SIGNAL ON Break_C
  707.  
  708.     AllocateBitmap bwidth bheight bdepth
  709.     IF RC = 0 THEN DO
  710.         tbmap.0 = RESULT
  711.  
  712.         AllocateBitmap bwidth bheight bdepth
  713.         IF RC = 0 THEN DO
  714.             tbmap.1 = RESULT
  715.  
  716.             SetBrushAttributes 'FRAMEFIRST 1 FRAMELAST' frames 'LENGTH' frames
  717.             Set '"ICONS = 0"'
  718.  
  719.             DO frm = 1 TO frames
  720.                 SetCurrentBrush 'BRUSH' bshnum
  721.                 IF RC ~= 0 THEN DO
  722.                     err_msg = txt_err_nomem
  723.                     BREAK
  724.                 END
  725.  
  726.                 SetBrushAttributes 'FRAMEPOSITION' frm
  727.                 IF RC ~= 0 THEN DO
  728.                     err_msg = txt_err_nomem
  729.                     BREAK
  730.                 END
  731.  
  732.                 GetBitmap '0 0 BITMAP' tbmap.tbnum 'FROMBRUSH'
  733.                 tbnum = 1 - tbnum
  734.  
  735.                 GetBrushColors
  736.                 local_plt = RESULT
  737.  
  738.                 IF frm = 1 THEN DO
  739.                     dx0 = 0
  740.                     dy0 = 0
  741.                     dx1 = bwidth - 1
  742.                     dy1 = bheight - 1
  743.                     global_plt = local_plt
  744.                 END
  745.                 ELSE DO
  746. /*****MODIFICATION**to make pgm obey host variable= optimization*******/
  747.                     /*IF transp = 1 THEN*/
  748.                         if optimization < 2 then GetBrushAttributes 'BOUNDARIES'
  749.                     ELSE
  750.                         GetBitmapDelta tbmap.0 tbmap.1
  751. /****MODIFICATION***to force using entire image values if optimization=0**********/
  752.                     if optimization > 0 then PARSE VAR RESULT dx0 dy0 dx1 dy1 .
  753. /********and that's all!****basically the original program functions as always**************/
  754.                     IF dx0 < 0 THEN DO
  755.                         dx0 = 0
  756.                         dy0 = 0
  757.                         dx1 = 0
  758.                         dy1 = 0
  759.                     END
  760. /********MODIFICATION***remove the IExplorer bug accomodation**which creates problems for multiple palette animbrushes in nontransp mode*****/
  761.  
  762.                 END
  763.  
  764.                 SetCurrentBrush 'BRUSH' tbshnum
  765.                 IF RC ~= 0 THEN DO
  766.                     err_msg = txt_err_nomem
  767.                     BREAK
  768.                 END
  769.  
  770.                 CopyBrush bshnum dx0 dy0 dx1 dy1 'NOFRAMES'
  771.                 IF RC ~= 0 THEN DO
  772.                     err_msg = txt_err_nomem
  773.                     BREAK
  774.                 END
  775.  
  776.                 SaveBrush tempfile 'FORCE QUIET NOPROGRESS FORMAT "GIF" OPTIONS "GIF89=1" "PROGDSP=0" "SCRFMT=0"'
  777.                 IF RC ~= 0 THEN DO
  778.                     IF RC = 46 | RC = 47 THEN
  779.                         err_msg = txt_err_oldlib
  780.                     ELSE
  781.                         err_msg = txt_err_nosave
  782.                     BREAK
  783.                 END
  784.  
  785.                 IF ~OPEN('tfile', tempfile, 'R') THEN DO
  786.                     err_msg = txt_err_nosave
  787.                     BREAK
  788.                 END
  789.  
  790.                 IF frm = 1 THEN DO
  791.                     IF ~OPEN('gfile', fname, 'W') THEN DO
  792.                         err_msg = txt_err_nosave
  793.                         BREAK
  794.                     END
  795.                     gfile_open = 1
  796.                     data = READCH('tfile', 13)      /* sign + screen descriptor */
  797.                     bxpix = BITOR(BITAND(SUBSTR(data, 11, 1), '07'x), '80'x)
  798.                     CALL WRITECH('gfile', data)
  799.  
  800.                     plt_data = READCH('tfile', plt_size)    /* palette */
  801.                     CALL WRITECH('gfile', plt_data)
  802.                     do_plt = 0
  803.  
  804.                     IF use_loop THEN
  805.                         CALL WRITECH('gfile', '21FF0B'x || 'NETSCAPE2.0' || '0301'x || IntelWord(loop) || '00'x)
  806.  
  807.                     IF annot ~= '' THEN DO      /* annotation */
  808.                         CALL WRITECH('gfile', '21FE'x)
  809.                         alen = LENGTH(annot)
  810.                         apos = 1
  811.                         DO WHILE alen > 0
  812.                             IF alen <= 255 THEN
  813.                                 aln = alen
  814.                             ELSE
  815.                                 aln = 255
  816.                             CALL WRITECH('gfile', D2C(aln) || SUBSTR(annot, apos, aln))
  817.                             apos = apos + aln
  818.                             alen = alen - aln
  819.                         END
  820.                         CALL WRITECH('gfile', '00'x)
  821.                     END
  822.                 END
  823.                 ELSE DO
  824.                     CALL SEEK('tfile', 13, 'B')
  825.                     plt_data = READCH('tfile', plt_size)
  826.                     do_plt = (global_plt ~== local_plt)
  827.                 END
  828.  
  829.                 DO FOREVER
  830.                     code = READCH('tfile', 1)
  831.  
  832.                     IF code = ',' THEN DO   /* image */
  833.                         /* gfx control */
  834.                         CALL WRITECH('gfile', '21F904'x || pckinfo || IntelWord(delay.frm) || D2C(transpcol) || '00'x)
  835.  
  836.                         data = READCH('tfile', 9)       /* Get image descriptor */
  837.                         imginfo = SUBSTR(data, 9, 1)
  838.                         IF do_plt THEN
  839.                             imginfo = BITOR(BITAND(imginfo, '40'x), bxpix)
  840.  
  841.                         /* image descriptor */
  842.                         CALL WRITECH('gfile', ',' || IntelWord(dx0) || IntelWord(dy0) || IntelWord(dx1-dx0+1) || IntelWord(dy1-dy0+1) || imginfo)
  843.  
  844.                         IF do_plt THEN
  845.                             CALL WRITECH('gfile', plt_data)
  846.  
  847.                         tpos = SEEK('tfile', 0, 'C')
  848.                         epos = SEEK('tfile', 0, 'E')
  849.                         dsize = epos - tpos - 1
  850.                         CALL SEEK('tfile', tpos, 'B')
  851.  
  852.                         /* image data */
  853.                         DO WHILE dsize > 0
  854.                             IF dsize > 65000 THEN
  855.                                 tsize = 65000
  856.                             ELSE
  857.                                 tsize = dsize
  858.                             data = READCH('tfile', tsize)
  859.                             CALL WRITECH('gfile', data)
  860.                             dsize = dsize - tsize
  861.                         END
  862.                         BREAK
  863.                     END
  864.                     ELSE IF code = '!' THEN DO      /* extension */
  865.                         CALL SEEK('tfile', 1, 'C')
  866.                         length = 1
  867.                         DO WHILE length ~= 0
  868.                             length = C2D(READCH('tfile', 1))
  869.                             IF length > 0 THEN
  870.                                 CALL SEEK('tfile', length, 'C')
  871.                         END
  872.                     END
  873.                     ELSE BREAK
  874.                 END
  875.  
  876.                 CALL CLOSE('tfile')
  877.             END
  878.  
  879.             CALL WRITECH('gfile', ';')
  880.             CALL CLOSE('gfile')
  881.             gfile_open = 0
  882.  
  883.             ADDRESS COMMAND 'Delete >NIL: 'tempfile
  884.  
  885.             SetCurrentBrush 'BRUSH' tbshnum
  886.             IF RC = 0 THEN
  887.                 FreeBrush 'FORCE'
  888.  
  889.             SetCurrentBrush 'BRUSH' bshnum
  890.             IF RC = 0 THEN
  891.                 SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
  892.  
  893.             Set '"ICONS =' sv_icons '"'
  894.  
  895.             FreeBitmap tbmap.1
  896.         END
  897.         ELSE err_msg = txt_err_nomem
  898.  
  899.         FreeBitmap tbmap.0
  900.     END
  901.     ELSE err_msg = txt_err_nomem
  902.  
  903.     IF err_msg ~= '' THEN
  904.         RequestNotify 'PROMPT "'err_msg'"'
  905.  
  906.     Set '"PATHBSH=""'sv_pathbsh'"" "'
  907. END
  908. UnlockGUI
  909.  
  910. EXIT 0
  911.  
  912.  
  913.  
  914.  
  915. IntelWord: PROCEDURE
  916.  
  917.     value = ARG(1)
  918.  
  919.     hibyte = value % 256
  920.     lobyte = value - (hibyte * 256)
  921.  
  922.     RETURN D2C(lobyte) || D2C(hibyte)
  923.  
  924.  
  925.  
  926.  
  927. Break_C:
  928.  
  929.     IF gfile_open THEN
  930.         CALL CLOSE('gfile')
  931.  
  932.     ADDRESS COMMAND 'Delete >NIL: 'tempfile
  933.  
  934.     SetCurrentBrush 'BRUSH' tbshnum
  935.     IF RC = 0 THEN
  936.         FreeBrush 'FORCE'
  937.  
  938.     SetCurrentBrush 'BRUSH' bshnum
  939.     IF RC = 0 THEN
  940.         SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
  941.  
  942.     Set '"ICONS =' sv_icons '"'
  943.  
  944.     IF tbmap.1 ~= 0 THEN
  945.         FreeBitmap tbmap.1
  946.  
  947.     IF tbmap.0 ~= 0 THEN
  948.         FreeBitmap tbmap.0
  949.  
  950.     Set '"PATHBSH=""'sv_pathbsh'"" "'
  951.  
  952.     RETURN
  953.